//
//  DelectView.m
//  CheckInforDemo
//
//  Created by bob on 2017/9/28.
//  Copyright © 2017年 bob. All rights reserved.
//

#import "DelectView.h"

@implementation DelectView

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self=[super initWithFrame:frame]) {
        
        self=[[[NSBundle mainBundle]loadNibNamed:@"DelectView" owner:self options:nil]lastObject];
        self.frame=frame;
   
    }
    
    return self;
}


- (IBAction)delectAction:(UIButton *)sender {
    
    
    _block(3);
    
}

- (IBAction)SelectAllBtn:(UIButton *)sender {
    
    sender.selected=!sender.selected;
    
    if (sender.selected) {
        
    _block(1);
        
    }else{
    
    _block(2);
        
    }
}

-(void)SelectNum:(NSInteger)num
{
    if (num==0) {
        
        [self.DelectBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        if(self.tag == 999999)
        {
            [self.DelectBtn setTitle:@"确认" forState:UIControlStateNormal];
        }else{
            [self.DelectBtn setTitle:@"删除" forState:UIControlStateNormal];
        }
        
        self.DelectBtn.enabled=NO;
        
    }else{
        
        self.DelectBtn.enabled=YES;
        
        [self.DelectBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        
        if(self.tag == 999999)
        {
            [self.DelectBtn setTitle:[NSString stringWithFormat:@"确认(%ld)",num] forState:UIControlStateNormal];
        }else{
            [self.DelectBtn setTitle:[NSString stringWithFormat:@"删除(%ld)",num] forState:UIControlStateNormal];
        }
        
    }

}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
